package org.dong.Control;

import com.alibaba.fastjson.JSON;
import org.dong.Annotation.MyControl;
import org.dong.Annotation.MyRequestMapping;
import org.dong.Tool.ApplicationUtil;
import org.dong.pojo.Dto;
import org.dong.pojo.Meal;
import org.dong.service.MealService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class MealControl {

    @PostMapping("/Meal/getMealList")
    public Dto getMealList(HttpServletRequest req, HttpServletResponse resp) throws IOException {

        Dto dto = new Dto();


        MealService mealService = (MealService) ApplicationUtil.getContext().getBean("mealService");
        List<Meal> mealList = mealService.getMealList();

        Map<String, Object> datas = new HashMap<String, Object>();
        datas.put("list", mealList);
        dto.setDatas(datas);
        dto.setErrMsg("套餐列表");
        dto.setStatusCode(200);

        return dto;
    }
}
